package com.daydayup.learn;


import lombok.extern.slf4j.Slf4j;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class CouponController {

    @Resource
    private CouponService couponService;

    @Resource
    private CustomerService customerService;

    @RequestMapping("/index")
    @ExceptionHandler(value = Exception.class)
    public String index(ModelMap modelMap) {
        System.out.println(modelMap.get("words"));
        return modelMap.get("words").toString();
    }

    @GetMapping("/coupon/sendv1")
    @ExceptionHandler(RuntimeException.class)
    public void sendv1(){
        int i = 10 / 0;
        couponService.batchTaskAction();
    }

    @GetMapping("/customer/findCustomer")
    public void findCustomer(){
        customerService.findCustomer();
        customerService.findCustomerByCompletableFuture();
    }
}
